# -*- coding: utf-8 -*-
# @Time    : 2022/5/25 2:13
# @Author  : leijiu
# @Email   : 517711635@qq.com
# @File    : add_goodsclass_page.py
# @Software: PyCharm
"""
添加商品分类页面
"""
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

class AddGoodsClass():
    def __init__(self,driver):
        self.driver=driver
    # 添加、编辑商品分类定位器
    ele_goodsclassname_locator = (By.NAME, "cat_name")
    ele_goodsclassbtn_locator = (By.CSS_SELECTOR, "body > div.main-div > form > div > input[type=submit]:nth-child(1)")
    ele_goodssort_locator = (By.XPATH,"/html/body/div[1]/form/table/tbody/tr[4]/td[2]/input")
    #输入分类名称
    def goodsclassname(self):
        self.driver.find_element(*self.ele_goodsclassname_locator).clear()
        self.driver.find_element(*self.ele_goodsclassname_locator).send_keys("衣服类")
        self.driver.find_element(*self.ele_goodssort_locator).clear()
        self.driver.find_element(*self.ele_goodssort_locator).send_keys("1")
        # 点击确定
    def goodsclassbtn(self):
        self.driver.find_element(*self.ele_goodsclassbtn_locator).click()
    #回到分类列表
    def backgoodslist(self):
        self.driver.find_element(By.XPATH,"/html/body/h1/span[1]/a").click()
    #断言添加的类名称
    def getgoodsclassname(self):
        new_goodsclassname = self.driver.find_element(By.XPATH,'/html/body/form/div/table/tbody/tr[2]/td[1]/span/a').text
        return new_goodsclassname
